{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# Here is the notebook where we developed intuition about the problem\n",
    "# This is, we believe, a good example of visualization driven developement for deep learning\n",
    "\n",
    "%pylab inline\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "def pony(I, r):\n",
    "    assert len(I.shape) == 3\n",
    "    assert r>0\n",
    "    r = int(r)\n",
    "    O = np.zeros((I.shape[0]*r, I.shape[1]*r, I.shape[2]/(r*2)))\n",
    "    for x in range(O.shape[0]):\n",
    "        for y in range(O.shape[1]):\n",
    "            for c in range(O.shape[2]):\n",
    "                c += 1\n",
    "                a = np.floor(x/r).astype(\"int\")\n",
    "                b = np.floor(y/r).astype(\"int\")\n",
    "                d = c*r*(y%r) + c*(x%r)\n",
    "                print a, b, d\n",
    "                O[x, y, c-1] = I[a, b, d]\n",
    "    return O"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "I = np.concatenate([np.ones((8, 8, 1))*0, 20*np.ones((8, 8, 1)), 30*np.ones((8, 8, 1)), 40*np.ones((8, 8, 1))], axis=-1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.image.AxesImage at 0x7f9532c97b50>"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAP4AAAD7CAYAAABKWyniAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAADM1JREFUeJzt3X+s3XV9x/Hnq9RFlJ/+gQQaKMyBC4myJkMncesEY4MJ\n+M+S4hIF/1UguhgQkrHyx2JMjCMw/yAqQQMzsZ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kRNvbBt7+fUxOGL7C5IHmWuB0YPv0/5ttwGmN8/YyObu+a/r19ZZ5h93+\nLPCulv+GfmRX6lA3J/ck/Y7Flzpk8aUOWXypQxZf6pDFlzpk8aUOWXypQ/8PzlW1q8n+n1cAAAAA\nSUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7f9532dac610>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "imshow(O[:, :, 0], interpolation=\"none\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.image.AxesImage at 0x7f9532bdd850>"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAP4AAAD7CAYAAABKWyniAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAADGJJREFUeJzt3V2sZXV5x/HvD0YjiLyYiDhMYEMt2JAonaRoJbangnGC\nCeNNk8EmCt5aINoYEJsiXhETY0nVC6ISNFATRxO4wDqdTMakbbTiMLwOOAkODEwZY6w1pgnl5enF\n3oMbOGc4s9fLYeb//SQnWXutddbzX3Pmt9fL3llPqgpJbTlurQcgaXwGX2qQwZcaZPClBhl8qUEG\nX2rQuqELJPHzQmmNVFWWmz948Kf+YYX5O4GlZZf8/Yv/t1ClL37t5hWXfeEe+MJlKyy7eqFyfHHF\nfYNW9+9Y3jcYf/9uWnD/bjrMsk6n+kk2JXk0yS+SXNdlW5LGs3DwkxwHfBX4MHABcEWSd/U1MEnD\n6XLEvwjYW1VPVNVzwHeBzUe2iUmH8kdu6Y9HLYf7159jed9g/P3rEvwzgf1zr5+azTsCkw7lj5z/\nefo2Ga3SsbxvcHQFX9JRqstd/aeBs+Zeb5jNW8bOuekJY7+bSi3YN/tZjS7B/xnwziRnA/8FbAGu\nWH7VpQ5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ks9Bwe0DtgIfK2qNgL/y/S0eBBJTmV69D0b\nWA+clOSw3ZYGMsrn0Ek+DzxXVXcOWONQB+ob52cPVQ/WJvhPA2fNvd4wmzeY2SnpVuA7VXXXkLWA\ni4HLkzwO/DPwV0m+PWC9p5geKe6dvd7K9I1gKJcCj1fVb6rqBeAHwPsHrHfIwSRvB0hyBrBCZ+b+\nJLmS6SXb0G9s8x2of8kfOlAPdlazFsH/GfDOJGfP7gZvAYa+8/0t4JGqumXgOlTVDVV11qyn4BZg\nR1V9fMB6B4H9Sc6bzbqEYW8qPgm8L8mbZm3SL2GYm4mvPFu6G7hyNv0JoO838JfVS7KJ6eXa5VX1\nbM+1Xlavqh6qqjOq6tyqOofpm/mfrtx2vgdVNfoPsAl4jOnd0usHrnUx8AKwG7gP2AVsGmk//xK4\ne4Q672H6hrqb6RH4lIHr3cg07A8wvdH2hp63fyfTG4bPMn2juQo4Ddg++3+zDTh14Hp7md5d3zX7\n+fqQ9V6x/HHgrUP+Df3KrtSgZm7uSfoDgy81yOBLDTL4UoMMvtQggy81yOBLDTL4UoP+H96/a4zL\nqiRhAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7f9532c3c1d0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "imshow(I.reshape(16, 16), interpolation=\"none\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(128, 2)\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "<matplotlib.image.AxesImage at 0x7f953298a650>"
      ]
     },
     "execution_count": 52,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAADEAAAD/CAYAAABYfj7YAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAACIVJREFUeJztnWuMXVUVx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QBZ1SJIKNp5wo4tTIiRJK0Xe9ErRL0iN+JbqRz6atFNWyMGoz8OExbduAxWZ2KU5IWQMg\n6RLcddl3AdcBm3xtRVVRllJkZtvNbNhvPoW7hA8zVIryUt0FsAr4lX8/I6WoUghKbElrgQEz+0lZ\nxut9g4qkFcD1wLJM84yUopo+uwsn5+7JbHfg1vxrGdNvRAJuxi07WRMJeDoOPAS8DJzEVXStxCXs\nIeA5/9qU6b/GH3wvcO1kIovUZd8cXm13D28IcmJKOpnZJydo3jxJ/zuBO6cat5I4NX6xGwFpFpsX\nRJETdXVi1i2f5dM7BjhGCyz7Q9nj1NUJeIlDTwzxj3F3Is0MdXWiq2MnT3SDWluDxqlvYp/Rxllt\nbZw+b17QMEH12EGGpXGGrcx67Lo5UUlE8TuRnMgLauKEpA5JJ9ziCjJJJ8euceMv/Qxn+gxIOjKd\n8avuhKQCcDfujs1f4v5czQK+l+lzHe5f4THgf7g/VM+a2YJxA06AWkRiCcW7NdcB/wL+y+g1bm4A\nTgB/xznbBJw9csfnVKiFE/NxB9gEvIK7wRFgzpg+zcB5uIV93gG8HfjWdAxUdNoh6XEge/aEW4xk\n3OIjjL8h+ATu6uF+3BMUFgOfl/Sgv4BXEhV1wsyuGdsm6Qrcs+UHgXm4hwsA/DvTrR84DZhjZgcl\nzcadgP8AHwQmdaIWdHoaeAswBHwRR6PZjF7jpgdoAb4k6UO4k2vAG/3+k6NG98B24M6qZV4ngD8D\nzwK7cQ8JH858fhL4wXTGT3OnvCA5kRckJ/KC5ERe8H8hdLjMWj5wOgAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7f9532ace410>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "A = I.reshape(-1, 2, 2)\n",
    "A = np.concatenate([i for i in A], axis=0)\n",
    "print A.shape\n",
    "imshow(A, interpolation=\"none\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "B = I.reshape(8, 8, 2, 2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(8, 16, 2)\n"
     ]
    }
   ],
   "source": [
    "B = np.concatenate([B[i] for i in range(8)], axis=1)\n",
    "print B.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(16, 2, 8)\n"
     ]
    }
   ],
   "source": [
    "B = B.transpose(1, 2, 0)\n",
    "print B.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(16, 16)\n"
     ]
    }
   ],
   "source": [
    "B = np.concatenate([B[:, :, i] for i in range(8)], axis=1)\n",
    "print B.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.image.AxesImage at 0x7f95327eb610>"
      ]
     },
     "execution_count": 71,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAP4AAAD7CAYAAABKWyniAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAADN9JREFUeJzt3W/MnXV9x/H3p5RFhPHHRGTQQGEGXEiUNRk6iVsnGBtM\nwCdLiksUfOqE6GJAWEYgW2ZMjGNzPiAqQQMzsZrAA/90TVMyXXRiKX8LNsFBgVFjnDNmCaPw3YNz\nWm/KfZf2nOt3HXr/3q/kTu7z5z6f30X5nOs61zn3/U1VIakvaxa9AEnjs/hShyy+1CGLL3XI4ksd\nsvhSh9a2Dkji+4XSglRVlru+efEn/maF63cAG5e95aaX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lib.figure.Figure at 0x7f9532ace490>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "imshow(B, interpolation=\"none\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def pony2(I, r):\n",
    "    B = I.reshape(8, 8, 2, 2).transpose(0, 1, 3, 2)\n",
    "    B = np.concatenate([B[i] for i in range(8)], axis=1)\n",
    "    B = B.transpose(1, 2, 0)\n",
    "    B = np.concatenate([B[:, :, i] for i in range(8)], axis=1)\n",
    "    return B"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.image.AxesImage at 0x7f953276ee90>"
      ]
     },
     "execution_count": 73,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAP4AAAD7CAYAAABKWyniAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAADM1JREFUeJzt3X+s3XV9x/Hnq9RFlJ/+gQQaKMyBC4myJkMncesEY4MJ\n+M+S4hIF/1UguhgQkrHyx2JMjCMw/yAqQQMzsZrAH252TVOSbdGJpfws0AQDBUaNcc6YJYyW9/44\np3ip95b2nO/ne+j9PB/JTe75cb+vz5fyOud7vufc+05VIakvaxa9AEnjs/hShyy+1CGLL3XI4ksd\nsvhSh9a2Dkji+4XSglRVlru+efEn/naF63cCG5e95bU7bpspac11K2WZN1beat63ReTVnbPl5XNH\nWMtMWzy04WRTkqeSPJPkxnm2JWk8Mxc/yRrgTuBjwEXA1UneO9TCJLUzzzP+JcDeqnquql4Fvgtc\ndWybWD9H/CzMO37zxsxa/XnzFP9sYN+Syy9MrzsG6+eIn4V5x2/emFmrP8+386QOzXNW/0XgnCWX\n102vW8bOJd+vZ/xHU2n12/kM7Nx7dPedp/g/Bd6T5Fzgv4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pTi7VR68/g94BfCNljnTrFOAD1fV3QBVdaCqftM49gTgnUnWAu8A\nXhpy4ytMaL4KuGf6/T3AJ1rmVdX2qnptevHHTEbFNcubGm0C9SKKfzawb8nlF2hcxEMyGdp3MfCT\nxlGH/gHHeMvkPOCXSe6evrS4azrYtImqegn4KvA88CLw66ra3ipviTOqav90DS8DZ4yQechngCMM\npJrf2BOouzm5l+QkYCtww/SZv1XOx4H906OM12cONrQW2AD8Y1VtAP6XyWFxE0lOY/Lsey5wFnBS\nkiNOW2pklPehk9wCvFpV9zXMODSB+talV7fKg8UU/0XgnCWX102va2Z6SLoV+E5V3d8yC7gUuDLJ\ns8A/AX+Z5NsN815g8kzx0PTyViYPBK1cDjxbVb+qqoPAD4APNcw7ZH+SdwMkORNYdjLzkJJcw+Ql\nW+sHtqUTqH/O7yZQNzuqWUTxfwq8J8m507PBm4HWZ76/BTxZVbc3zqGqbq6qc6YzBTcDO6rqUw3z\n9gP7klwwveoy2p5UfB74YJK3T8ekX0abk4mHHy09AFwz/f7TwNAP4G/IS7KJycu1K6vqlYGz3pBX\nVY9X1ZlVdX5VncfkwfxPVho7P4iqGv0L2AQ8zeRs6U2Nsy4FDgK7gYeBXcCmkfbzL4AHRsh5P5MH\n1N1MnoFPbZx3K5OyP8rkRNvbBt7+fUxOGL7C5IHmWuB0YPv0/5ttwGmN8/YyObu+a/r19ZZ5h93+\nLPCulv+GfmRX6lA3J/ck/Y7Flzpk8aUOWXypQxZf6pDFlzpk8aUOWXypQ/8PzlW1q8n+n1cAAAAA\nSUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7f9532802410>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "B = pony2(I)\n",
    "imshow(B, interpolation=\"none\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0 0 0\n",
      "0 0 2\n",
      "0 1 0\n",
      "0 1 2\n",
      "0 2 0\n",
      "0 2 2\n",
      "0 3 0\n",
      "0 3 2\n",
      "0 4 0\n",
      "0 4 2\n",
      "0 5 0\n",
      "0 5 2\n",
      "0 6 0\n",
      "0 6 2\n",
      "0 7 0\n",
      "0 7 2\n",
      "0 0 1\n",
      "0 0 3\n",
      "0 1 1\n",
      "0 1 3\n",
      "0 2 1\n",
      "0 2 3\n",
      "0 3 1\n",
      "0 3 3\n",
      "0 4 1\n",
      "0 4 3\n",
      "0 5 1\n",
      "0 5 3\n",
      "0 6 1\n",
      "0 6 3\n",
      "0 7 1\n",
      "0 7 3\n",
      "1 0 0\n",
      "1 0 2\n",
      "1 1 0\n",
      "1 1 2\n",
      "1 2 0\n",
      "1 2 2\n",
      "1 3 0\n",
      "1 3 2\n",
      "1 4 0\n",
      "1 4 2\n",
      "1 5 0\n",
      "1 5 2\n",
      "1 6 0\n",
      "1 6 2\n",
      "1 7 0\n",
      "1 7 2\n",
      "1 0 1\n",
      "1 0 3\n",
      "1 1 1\n",
      "1 1 3\n",
      "1 2 1\n",
      "1 2 3\n",
      "1 3 1\n",
      "1 3 3\n",
      "1 4 1\n",
      "1 4 3\n",
      "1 5 1\n",
      "1 5 3\n",
      "1 6 1\n",
      "1 6 3\n",
      "1 7 1\n",
      "1 7 3\n",
      "2 0 0\n",
      "2 0 2\n",
      "2 1 0\n",
      "2 1 2\n",
      "2 2 0\n",
      "2 2 2\n",
      "2 3 0\n",
      "2 3 2\n",
      "2 4 0\n",
      "2 4 2\n",
      "2 5 0\n",
      "2 5 2\n",
      "2 6 0\n",
      "2 6 2\n",
      "2 7 0\n",
      "2 7 2\n",
      "2 0 1\n",
      "2 0 3\n",
      "2 1 1\n",
      "2 1 3\n",
      "2 2 1\n",
      "2 2 3\n",
      "2 3 1\n",
      "2 3 3\n",
      "2 4 1\n",
      "2 4 3\n",
      "2 5 1\n",
      "2 5 3\n",
      "2 6 1\n",
      "2 6 3\n",
      "2 7 1\n",
      "2 7 3\n",
      "3 0 0\n",
      "3 0 2\n",
      "3 1 0\n",
      "3 1 2\n",
      "3 2 0\n",
      "3 2 2\n",
      "3 3 0\n",
      "3 3 2\n",
      "3 4 0\n",
      "3 4 2\n",
      "3 5 0\n",
      "3 5 2\n",
      "3 6 0\n",
      "3 6 2\n",
      "3 7 0\n",
      "3 7 2\n",
      "3 0 1\n",
      "3 0 3\n",
      "3 1 1\n",
      "3 1 3\n",
      "3 2 1\n",
      "3 2 3\n",
      "3 3 1\n",
      "3 3 3\n",
      "3 4 1\n",
      "3 4 3\n",
      "3 5 1\n",
      "3 5 3\n",
      "3 6 1\n",
      "3 6 3\n",
      "3 7 1\n",
      "3 7 3\n",
      "4 0 0\n",
      "4 0 2\n",
      "4 1 0\n",
      "4 1 2\n",
      "4 2 0\n",
      "4 2 2\n",
      "4 3 0\n",
      "4 3 2\n",
      "4 4 0\n",
      "4 4 2\n",
      "4 5 0\n",
      "4 5 2\n",
      "4 6 0\n",
      "4 6 2\n",
      "4 7 0\n",
      "4 7 2\n",
      "4 0 1\n",
      "4 0 3\n",
      "4 1 1\n",
      "4 1 3\n",
      "4 2 1\n",
      "4 2 3\n",
      "4 3 1\n",
      "4 3 3\n",
      "4 4 1\n",
      "4 4 3\n",
      "4 5 1\n",
      "4 5 3\n",
      "4 6 1\n",
      "4 6 3\n",
      "4 7 1\n",
      "4 7 3\n",
      "5 0 0\n",
      "5 0 2\n",
      "5 1 0\n",
      "5 1 2\n",
      "5 2 0\n",
      "5 2 2\n",
      "5 3 0\n",
      "5 3 2\n",
      "5 4 0\n",
      "5 4 2\n",
      "5 5 0\n",
      "5 5 2\n",
      "5 6 0\n",
      "5 6 2\n",
      "5 7 0\n",
      "5 7 2\n",
      "5 0 1\n",
      "5 0 3\n",
      "5 1 1\n",
      "5 1 3\n",
      "5 2 1\n",
      "5 2 3\n",
      "5 3 1\n",
      "5 3 3\n",
      "5 4 1\n",
      "5 4 3\n",
      "5 5 1\n",
      "5 5 3\n",
      "5 6 1\n",
      "5 6 3\n",
      "5 7 1\n",
      "5 7 3\n",
      "6 0 0\n",
      "6 0 2\n",
      "6 1 0\n",
      "6 1 2\n",
      "6 2 0\n",
      "6 2 2\n",
      "6 3 0\n",
      "6 3 2\n",
      "6 4 0\n",
      "6 4 2\n",
      "6 5 0\n",
      "6 5 2\n",
      "6 6 0\n",
      "6 6 2\n",
      "6 7 0\n",
      "6 7 2\n",
      "6 0 1\n",
      "6 0 3\n",
      "6 1 1\n",
      "6 1 3\n",
      "6 2 1\n",
      "6 2 3\n",
      "6 3 1\n",
      "6 3 3\n",
      "6 4 1\n",
      "6 4 3\n",
      "6 5 1\n",
      "6 5 3\n",
      "6 6 1\n",
      "6 6 3\n",
      "6 7 1\n",
      "6 7 3\n",
      "7 0 0\n",
      "7 0 2\n",
      "7 1 0\n",
      "7 1 2\n",
      "7 2 0\n",
      "7 2 2\n",
      "7 3 0\n",
      "7 3 2\n",
      "7 4 0\n",
      "7 4 2\n",
      "7 5 0\n",
      "7 5 2\n",
      "7 6 0\n",
      "7 6 2\n",
      "7 7 0\n",
      "7 7 2\n",
      "7 0 1\n",
      "7 0 3\n",
      "7 1 1\n",
      "7 1 3\n",
      "7 2 1\n",
      "7 2 3\n",
      "7 3 1\n",
      "7 3 3\n",
      "7 4 1\n",
      "7 4 3\n",
      "7 5 1\n",
      "7 5 3\n",
      "7 6 1\n",
      "7 6 3\n",
      "7 7 1\n",
      "7 7 3\n"
     ]
    }
   ],
   "source": [
    "I = np.arange(16*16).reshape(8, 8, 4)\n",
    "A = pony(I, 2)\n",
    "B = pony2(I)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.image.AxesImage at 0x7f95324132d0>"
      ]
     },
     "execution_count": 79,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAP4AAAD7C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0lrR9tYw/f/AK0dhq/ReqG5ETgV2Nr+f7MFOCVzvT209q5vb5++mLPerOv3AqflfA79\nlV2zClWzc8/MjnHwzSrk4JtVyME3q5CDb1YhB9+sQg6+WYUcfLMK/T90LNcW4MvK8QAAAABJRU5E\nrkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7f9532634250>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "imshow(A[:, :, 0], interpolation=\"none\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 80,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.image.AxesImage at 0x7f95324e0790>"
      ]
     },
     "execution_count": 80,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAP4AAAD7CAYAAABKWyniAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAD3VJREFUeJzt3WuMnNV9x/Hvz7vrC7jchICCZRtKIAiVUFflUpJ2GxLh\nJgqOqlaCNE0gEq+SgJIqgsALNm+qJFVCaUle0CQWbaGR4iDFaUPjWs6GtARyMeZmY1yZYsMWV1Gb\noJQEfPn3xcza683MsHvmOWd29vw+0kizM3Pmfzzj3zwzz5l5/ooIzKwuSwY9ATMrz8E3q5CDb1Yh\nB9+sQg6+WYUcfLMKjeYuIMnrhWYDEhHqdHn24Lfc2eXySWC8y3UrEmv1GvcQ8IcF6z0I/FHD9U7o\ncd0/AO9vuF6vcX8L3FSo1l8DNyeMS633GeDWgvUm2qdOOmZ3DrqP6+utvqT1kp6V9Jykbo+SmS0w\nycGXtAS4B7gGuBi4XtKbm5qYmeXTzxb/MmBPRLwQEQeBrwIb5ncXa/son+L8wvUuKlzvksL11hWs\ndXnBWgBXFa43XrRaP8E/B9g/4+8X25fNw9o+yqd4U+F6iz34v12wVungv7VwvfGi1bycZ1ahfvbq\nvwSsnvH3q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ezck7QS2ATc0t7y56rzbuBA+13G0Z6DGY0C64AvRMQ64FVab4uzkHQKra3vGuBsYKWknt2W\nMimyDi3pDuBgRDyQscZ0B+o7Z16cqx4MJvgvAatn/L2qfVk27bekm4C/j4hv5KwFXAVcK2kv8I/A\nH0j6u4z1XqS1pZj+qv4mWi8EubwD2BsR/xMRh4EHgd/NWG/aAUlnAkg6C+jYmblJkm6g9ZEt9wvb\nzA7Uz3OsA3W2dzWDCP4PgfMlrWnvDb4OyL3n+yvAzoi4O3MdIuL2iFjd7il4HbAtIj6Qsd4BYL+k\nC9oXXU3enYr7gCskLW+3Sb+aPDsTZ79b2gzc0D7/QaDpF/Dj6klaT+vj2rURkeN3pMd1oI6IsyLi\nvIg4l9aL+W91azvfiIgofgLW0/rl4x7gtsy1rgIO0/ox2ePAdmB9oX/n7wObC9R5C60X1B20tsAn\nZ653J62wP0lrR9tYw/f/AK0dhq/ReqG5ETgV2Nr+f7MFOCVzvT209q5vb5++mLPerOv3AqflfA79\nlV2zClWzc8/MjnHwzSrk4JtVyME3q5CDb1YhB9+sQg6+WYUcfLMK/T90LNcW4MvK8QAAAABJRU5E\nrkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7f95328e53d0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "imshow(B, interpolation=\"none\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 81,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[[   0.],\n",
       "        [   2.],\n",
       "        [   4.],\n",
       "        [   6.],\n",
       "        [   8.],\n",
       "        [  10.],\n",
       "        [  12.],\n",
       "        [  14.],\n",
       "        [  16.],\n",
       "        [  18.],\n",
       "        [  20.],\n",
       "        [  22.],\n",
       "        [  24.],\n",
       "        [  26.],\n",
       "        [  28.],\n",
       "        [  30.]],\n",
       "\n",
       "       [[   1.],\n",
       "        [   3.],\n",
       "        [   5.],\n",
       "        [   7.],\n",
       "        [   9.],\n",
       "        [  11.],\n",
       "        [  13.],\n",
       "        [  15.],\n",
       "        [  17.],\n",
       "        [  19.],\n",
       "        [  21.],\n",
       "        [  23.],\n",
       "        [  25.],\n",
       "        [  27.],\n",
       "        [  29.],\n",
       "        [  31.]],\n",
       "\n",
       "       [[  32.],\n",
       "        [  34.],\n",
       "        [  36.],\n",
       "        [  38.],\n",
       "        [  40.],\n",
       "        [  42.],\n",
       "        [  44.],\n",
       "        [  46.],\n",
       "        [  48.],\n",
       "        [  50.],\n",
       "        [  52.],\n",
       "        [  54.],\n",
       "        [  56.],\n",
       "        [  58.],\n",
       "        [  60.],\n",
       "        [  62.]],\n",
       "\n",
       "       [[  33.],\n",
       "        [  35.],\n",
       "        [  37.],\n",
       "        [  39.],\n",
       "        [  41.],\n",
       "        [  43.],\n",
       "        [  45.],\n",
       "        [  47.],\n",
       "        [  49.],\n",
       "        [  51.],\n",
       "        [  53.],\n",
       "        [  55.],\n",
       "        [  57.],\n",
       "        [  59.],\n",
       "        [  61.],\n",
       "        [  63.]],\n",
       "\n",
       "       [[  64.],\n",
       "        [  66.],\n",
       "        [  68.],\n",
       "        [  70.],\n",
       "        [  72.],\n",
       "        [  74.],\n",
       "        [  76.],\n",
       "        [  78.],\n",
       "        [  80.],\n",
       "        [  82.],\n",
       "        [  84.],\n",
       "        [  86.],\n",
       "        [  88.],\n",
       "        [  90.],\n",
       "        [  92.],\n",
       "        [  94.]],\n",
       "\n",
       "       [[  65.],\n",
       "        [  67.],\n",
       "        [  69.],\n",
       "        [  71.],\n",
       "        [  73.],\n",
       "        [  75.],\n",
       "        [  77.],\n",
       "        [  79.],\n",
       "        [  81.],\n",
       "        [  83.],\n",
       "        [  85.],\n",
       "        [  87.],\n",
       "        [  89.],\n",
       "        [  91.],\n",
       "        [  93.],\n",
       "        [  95.]],\n",
       "\n",
       "       [[  96.],\n",
       "        [  98.],\n",
       "        [ 100.],\n",
       "        [ 102.],\n",
       "        [ 104.],\n",
       "        [ 106.],\n",
       "        [ 108.],\n",
       "        [ 110.],\n",
       "        [ 112.],\n",
       "        [ 114.],\n",
       "        [ 116.],\n",
       "        [ 118.],\n",
       "        [ 120.],\n",
       "        [ 122.],\n",
       "        [ 124.],\n",
       "        [ 126.]],\n",
       "\n",
       "       [[  97.],\n",
       "        [  99.],\n",
       "        [ 101.],\n",
       "        [ 103.],\n",
       "        [ 105.],\n",
       "        [ 107.],\n",
       "        [ 109.],\n",
       "        [ 111.],\n",
       "        [ 113.],\n",
       "        [ 115.],\n",
       "        [ 117.],\n",
       "        [ 119.],\n",
       "        [ 121.],\n",
       "        [ 123.],\n",
       "        [ 125.],\n",
       "        [ 127.]],\n",
       "\n",
       "       [[ 128.],\n",
       "        [ 130.],\n",
       "        [ 132.],\n",
       "        [ 134.],\n",
       "        [ 136.],\n",
       "        [ 138.],\n",
       "        [ 140.],\n",
       "        [ 142.],\n",
       "        [ 144.],\n",
       "        [ 146.],\n",
       "        [ 148.],\n",
       "        [ 150.],\n",
       "        [ 152.],\n",
       "        [ 154.],\n",
       "        [ 156.],\n",
       "        [ 158.]],\n",
       "\n",
       "       [[ 129.],\n",
       "        [ 131.],\n",
       "        [ 133.],\n",
       "        [ 135.],\n",
       "        [ 137.],\n",
       "        [ 139.],\n",
       "        [ 141.],\n",
       "        [ 143.],\n",
       "        [ 145.],\n",
       "        [ 147.],\n",
       "        [ 149.],\n",
       "        [ 151.],\n",
       "        [ 153.],\n",
       "        [ 155.],\n",
       "        [ 157.],\n",
       "        [ 159.]],\n",
       "\n",
       "       [[ 160.],\n",
       "        [ 162.],\n",
       "        [ 164.],\n",
       "        [ 166.],\n",
       "        [ 168.],\n",
       "        [ 170.],\n",
       "        [ 172.],\n",
       "        [ 174.],\n",
       "        [ 176.],\n",
       "        [ 178.],\n",
       "        [ 180.],\n",
       "        [ 182.],\n",
       "        [ 184.],\n",
       "        [ 186.],\n",
       "        [ 188.],\n",
       "        [ 190.]],\n",
       "\n",
       "       [[ 161.],\n",
       "        [ 163.],\n",
       "        [ 165.],\n",
       "        [ 167.],\n",
       "        [ 169.],\n",
       "        [ 171.],\n",
       "        [ 173.],\n",
       "        [ 175.],\n",
       "        [ 177.],\n",
       "        [ 179.],\n",
       "        [ 181.],\n",
       "        [ 183.],\n",
       "        [ 185.],\n",
       "        [ 187.],\n",
       "        [ 189.],\n",
       "        [ 191.]],\n",
       "\n",
       "       [[ 192.],\n",
       "        [ 194.],\n",
       "        [ 196.],\n",
       "        [ 198.],\n",
       "        [ 200.],\n",
       "        [ 202.],\n",
       "        [ 204.],\n",
       "        [ 206.],\n",
       "        [ 208.],\n",
       "        [ 210.],\n",
       "        [ 212.],\n",
       "        [ 214.],\n",
       "        [ 216.],\n",
       "        [ 218.],\n",
       "        [ 220.],\n",
       "        [ 222.]],\n",
       "\n",
       "       [[ 193.],\n",
       "        [ 195.],\n",
       "        [ 197.],\n",
       "        [ 199.],\n",
       "        [ 201.],\n",
       "        [ 203.],\n",
       "        [ 205.],\n",
       "        [ 207.],\n",
       "        [ 209.],\n",
       "        [ 211.],\n",
       "        [ 213.],\n",
       "        [ 215.],\n",
       "        [ 217.],\n",
       "        [ 219.],\n",
       "        [ 221.],\n",
       "        [ 223.]],\n",
       "\n",
       "       [[ 224.],\n",
       "        [ 226.],\n",
       "        [ 228.],\n",
       "        [ 230.],\n",
       "        [ 232.],\n",
       "        [ 234.],\n",
       "        [ 236.],\n",
       "        [ 238.],\n",
       "        [ 240.],\n",
       "        [ 242.],\n",
       "        [ 244.],\n",
       "        [ 246.],\n",
       "        [ 248.],\n",
       "        [ 250.],\n",
       "        [ 252.],\n",
       "        [ 254.]],\n",
       "\n",
       "       [[ 225.],\n",
       "        [ 227.],\n",
       "        [ 229.],\n",
       "        [ 231.],\n",
       "        [ 233.],\n",
       "        [ 235.],\n",
       "        [ 237.],\n",
       "        [ 239.],\n",
       "        [ 241.],\n",
       "        [ 243.],\n",
       "        [ 245.],\n",
       "        [ 247.],\n",
       "        [ 249.],\n",
       "        [ 251.],\n",
       "        [ 253.],\n",
       "        [ 255.]]])"
      ]
     },
     "execution_count": 81,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "A"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ True,  True,  True,  True,  True,  True,  True,  True,  True,\n",
       "         True,  True,  True,  True,  True,  True,  True],\n",
       "       [ True,  True,  True,  True,  True,  True,  True,  True,  True,\n",
       "         True,  True,  True,  True,  True,  True,  True],\n",
       "       [ True,  True,  True,  True,  True,  True,  True,  True,  True,\n",
       "         True,  True,  True,  True,  True,  True,  True],\n",
       "       [ True,  True,  True,  True,  True,  True,  True,  True,  True,\n",
       "         True,  True,  True,  True,  True,  True,  True],\n",
       "       [ True,  True,  True,  True,  True,  True,  True,  True,  True,\n",
       "         True,  True,  True,  True,  True,  True,  True],\n",
       "       [ True,  True,  True,  True,  True,  True,  True,  True,  True,\n",
       "         True,  True,  True,  True,  True,  True,  True],\n",
       "       [ True,  True,  True,  True,  True,  True,  True,  True,  True,\n",
       "         True,  True,  True,  True,  True,  True,  True],\n",
       "       [ True,  True,  True,  True,  True,  True,  True,  True,  True,\n",
       "         True,  True,  True,  True,  True,  True,  True],\n",
       "       [ True,  True,  True,  True,  True,  True,  True,  True,  True,\n",
       "         True,  True,  True,  True,  True,  True,  True],\n",
       "       [ True,  True,  True,  True,  True,  True,  True,  True,  True,\n",
       "         True,  True,  True,  True,  True,  True,  True],\n",
       "       [ True,  True,  True,  True,  True,  True,  True,  True,  True,\n",
       "         True,  True,  True,  True,  True,  True,  True],\n",
       "       [ True,  True,  True,  True,  True,  True,  True,  True,  True,\n",
       "         True,  True,  True,  True,  True,  True,  True],\n",
       "       [ True,  True,  True,  True,  True,  True,  True,  True,  True,\n",
       "         True,  True,  True,  True,  True,  True,  True],\n",
       "       [ True,  True,  True,  True,  True,  True,  True,  True,  True,\n",
       "         True,  True,  True,  True,  True,  True,  True],\n",
       "       [ True,  True,  True,  True,  True,  True,  True,  True,  True,\n",
       "         True,  True,  True,  True,  True,  True,  True],\n",
       "       [ True,  True,  True,  True,  True,  True,  True,  True,  True,\n",
       "         True,  True,  True,  True,  True,  True,  True]], dtype=bool)"
      ]
     },
     "execution_count": 83,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "B == A[:, :, 0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def pony2(I, r):\n",
    "    a, b, c = I.shape\n",
    "    B = I.reshape(a/r, b/r, r, r).transpose(0, 1, 3, 2)\n",
    "    B = np.concatenate([B[i] for i in range(8)], axis=1)\n",
    "    B = B.transpose(1, 2, 0)\n",
    "    B = np.concatenate([B[:, :, i] for i in range(8)], axis=1)\n",
    "    return B"
   ]
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python [Root]",
   "language": "python",
   "name": "Python [Root]"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
